package com.ruoyi.omp.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.omp.api.RemoteParkService;
import com.ruoyi.omp.api.domain.BuiBuilding;
import com.ruoyi.omp.api.domain.BuiPark;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class RemoteParkFactory implements FallbackFactory<RemoteParkService> {
    @Override
    public RemoteParkService create(Throwable throwable) {
        log.error("园区服务调用失败:{}", throwable.getMessage());
        return new RemoteParkService() {
            @Override
            public R<BuiPark> getPark(String parkId) {
                return R.fail("获取园区信息失败:" + throwable.getMessage());
            }

            @Override
            public R<BuiBuilding> getBuiding(String buidingId) {
                return R.fail("获取楼栋信息失败:" + throwable.getMessage());
            }
        };
    }
}
